<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">



    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('客户id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" class="form-control" data-rule="required" name="row[user_id]" type="text" value="">
        </div>
        <a href="javascript:;" name="users" class="btn btn-success" >{:__('查询')}</a>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('微信昵称')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="nickname" class="form-control"  readonly="readonly" type="text" value="">
        </div>
    </div>


    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('充值金额')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-money" class="form-control" data-rule="required" name="row[money]" type="text" value="">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('支付方式')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:build_radios('row[pay]', ['1'=>__('转账'), '2'=>__('现金'), '3'=>__('pos机'), '4'=>__('支付宝'), '5'=>__('微信')])}
        </div>
    </div>



    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script src="/assets/img/jquery-3.4.1.min.js"></script>
<script>

        $("a[name='users']").click(function(){
            let type =  $("#c-name").val();
            console.log(type);

            $.ajax({
                url:"financing/cost/for",    //请求的url地址
                dataType:"json",   //返回格式为json
                async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                data:{"id":type,},    //参数值
                type:"POST",   //请求方式
                success:function(data){
                    //请求成功时处理
                    if (data.code == 0) {
                        //console.log(data);
                        Toastr.error(data.msg);
                    }else {
                        //parent.Toastr.success(data.msg);
                        $("#nickname").attr("value",data.data);
                    }
                },
            });

        });


</script>